package com.southwind.springboottest.repository;

import com.southwind.springboottest.entity.BookCategory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface BookCategoryRepository extends JpaRepository<BookCategory, Integer> {
    @Query("SELECT MAX(b.bookcaseid) FROM BookCategory b")
    Integer findMaxBookcaseId();
    
    @Query("SELECT COUNT(b) FROM Book b WHERE b.bookcaseid = :bookcaseid")
    Integer countBooksByCategory(@Param("bookcaseid") Integer bookcaseid);
}
